package com.google.code.jmarias.common.action;

import com.google.code.jmarias.common.AbstractUser;
import com.google.code.jmarias.common.Card;
import com.google.code.jmarias.common.NewPlayer;
import com.google.code.jmarias.common.NewTable;

/**
 *
 * @author Ondrej Michal
 */
public class DealFiveHiddenCardsAction extends GameAction {

    private Card[] cards;
    private AbstractUser recipient;

    public DealFiveHiddenCardsAction() {
        cards = new Card[5];
        for (int i = 0; i < 5; i++) {
            cards[i] = new Card(null, null);
        }
    }

    public DealFiveHiddenCardsAction(Card[] cards, AbstractUser recipient) {
        this.cards = cards;
        this.recipient = recipient;
    }

    @Override
    public void updateTable(NewTable table, AbstractUser user) {
        for (NewPlayer player : table.getPlayers()) {
            if (player.getClient().equals(recipient)) {
                for (Card card : cards) {
                    player.addToHand(card);
                }
            }
        }
    }

    @Override
    public String toString() {
        return "Hraci " + recipient + " predlozeno 5 skrytych karet";
    }

    public Card[] getCards() {
        return cards;
    }

    public void setCards(Card[] cards) {
        this.cards = cards;
    }

    public AbstractUser getRecipient() {
        return recipient;
    }

    public void setRecipient(AbstractUser recipient) {
        this.recipient = recipient;
    }

}
